<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }

    .header, .footer, .pagination, .content {
      width: 1200px;
      margin: 0 auto;
    }

    .header, .footer {
      height: 100px;
      background-color: skyblue;
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 50px;
      color: #fff;
    }

    .pagination {
      height: 45px;
      margin: 10px auto;
      border: 1px solid #333;
    }

    .content {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
    }

    .content > li {
      list-style: none;
      width: 290px;
      height: 450px;
      border: 1px solid #333;
      margin-bottom: 10px;
    }

    .content > li > img {
      width: 100%;
      display: block;
    }
  </style>
</head>
<body>

  <div class="header">头部</div>
  <div class="pagination">
    <button>上一页</button>
    <button class="next">下一页</button>
  </div>
  <ul class="content">

  </ul>
  <div class="footer">底部</div>
  <script>
    let current = 1;
    const contentBox = document.querySelector('.content');
    const next = document.querySelector('.next');
    getList();
    function getList(){
        const xhr = new XMLHttpRequest();
        xhr.open('get', `http://localhost:8888/goods/list?current=${current}&pagesize=13`);
        xhr.onload = function () {
           const res = JSON.parse(xhr.responseText);
           bindhtml(res.list);
        }
        xhr.send();
    }

    function  bindhtml(list){
        contentBox.innerHTML = list.reduce((prev,item)=>{
            return prev + `<li>
                <img src="${item.img_big_logo}" alt="">
                <p>${item.title}</p>
                <p>${item.price}</p>
            </li>`
        },'')
    }

    next.onclick = function(){
        current++;
        getList();
    }
  </script>

</body>

</html> 